home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM Gold
/
Light ROM Gold.iso
/
arexx
/
modeler
/
wrapsphe.rex
< prev
Wrap
OS/2 REXX Batch file
|
1995-03-23
|
3KB
|
114 lines
From shf@well.sf.ca.us Tue Aug 10 19:12:41 1993
Return-Path: <shf@well.sf.ca.us>
Received: from RUTGERS.EDU by netcom3.netcom.com (5.65/SMI-4.1/Netcom)
id AA04569; Tue, 10 Aug 93 19:12:39 -0700
Received: from bobsbox.rent.com by rutgers.edu (5.59/SMI4.0/RU1.5/3.08) with UUCP
id AA15826; Tue, 10 Aug 93 16:25:37 EDT
Received: by bobsbox.rent.com (V1.16/Amiga)
id AA02zx1; Tue, 10 Aug 93 12:46:12 EDT
Received: from nkosi.well.sf.ca.us by rutgers.edu (5.59/SMI4.0/RU1.5/3.08)
id AA29623; Tue, 10 Aug 93 04:03:44 EDT
Received: from well.sf.ca.us (well.sf.ca.us [192.132.30.2]) by nkosi.well.sf.ca.us (8.5/8.5) with SMTP id BAA04606; Tue, 10 Aug 1993 01:03:40 -0700
Received: by well.sf.ca.us id <14046-2>; Tue, 10 Aug 1993 01:03:10 -0700
Message-Id: <93Aug10.010310pdt.14046-2@well.sf.ca.us>
Date: Tue, 10 Aug 1993 01:03:10 -0700
From: "Stuart H. Ferguson" <shf@well.sf.ca.us>
To: lightwave@bobsbox.rent.com
Subject: Conform to Sphere script
Status: OR
Having been challenged by Imagine's "Conform to Sphere" operation, I
sat down and wrote an ARexx script for Modeler 3.0 that does a
similar function. I only spent a few minutes on it, so it does not
have a lot of bells and whistles, but it does do essentially the
desired transformation. Hope this helps the fellow who wanted to
do this ...
Stuart Ferguson
-----------------------
/*
* Wrap Data onto Sphere -- Modeler ARexx transform.
*
* 8/93 Stuart Ferguson
*/
mxx="LWModelerARexx.port"
signal on error
signal on syntax
check = addlib("rexxmathlib.library",0,-30,0)
mxx_add = addlib(mxx,0)
call main
if (mxx_add) then call remlib(mxx)
exit
syntax:
error:
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
if (mxx_add) then call remlib(mxx)
exit
main:
syscode = "Wrap Sphere"
/* Get size and thickness of sphere from user.
*/
call req_begin syscode
id_inr = req_addcontrol("Inner Radius", 'n', 1)
id_otr = req_addcontrol("Outer Radius", 'n', 1)
id_sel = req_addcontrol("Points", 'c', 'All Selected')
call req_setval id_inr, 1.0, 1.0
call req_setval id_otr, 2.0, 2.0
call req_setval id_sel, 2
if (~req_post()) then return
r1 = req_getval(id_inr)
r2 = req_getval(id_otr)
call sel_mode word('global user',req_getval(id_sel))
call req_end
/* Get extent of data area. This will just take the extent in
* X and Y and map it to lat and long on the sphere, and the
* extent in Z and map it to r1 and r2.
*/
parse value boundingbox() with n x1 x2 y1 y2 z1 z2 .
dx = x2 - x1
dy = y2 - y1
dz = z2 - z1
if (n <= 0 | dx <= 0 | dy <= 0) then return
d2r = 3.1415926 / 180
/* Transform loop
*/
n = xfrm_begin()
call meter_begin n, syscode
do i = 1 to n
parse value xfrm_getpos(i) with x y z .
lat = d2r * ((y - y1) / dy * 180 - 90)
lon = d2r * ((x - x1) / dx * 360)
if (dz <= 0) then rad = r1
else rad = (z - z1) / dz * (r2 - r1) + r1
y = rad * sin(lat)
p = rad * cos(lat)
x = p * sin(lon)
z = p * cos(lon)
call xfrm_setpos i, x y z
call meter_step
end
call meter_end
call xfrm_end
return
------------------------- end